﻿using Microsoft.AspNetCore.Mvc.ApplicationModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Blog.Core.Common
{
    public class ApiExplorerIgnores : IActionModelConvention
    {
        /// <summary>
        /// Ocelot自带的Controller与swagger2.0冲突，在此排除扫描
        /// </summary>
        /// <param name="action"></param>
        public void Apply(ActionModel action)
        {
            //冲突的Ocelot.Raft.RaftController
            if (action.Controller.ControllerName.Equals("AddUserRole"))
                action.ApiExplorer.IsVisible = false;
            //Ocelot.Cache.OutputCacheController
            //if (action.Controller.ControllerName.Equals("OutputCache"))
            //    action.ApiExplorer.IsVisible = false;
        }
    }
}
